package com.ktjy.web;

import com.ktjy.entity.Auction;
import com.ktjy.mapper.AuctionMapper;
import my.framework.anno.RequestMapping;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Controller;
import com.ktjy.util.MyBatisUtil;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class AuctionServlet extends HttpServlet {

    @RequestMapping(value = "/auctionDetail")
    public void register(HttpServletRequest request, HttpServletResponse response) throws Exception {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        SqlSession sqlSession = null;
        try {
            sqlSession= MyBatisUtil.createSqlSession();
            AuctionMapper auctionMapper = sqlSession.getMapper(AuctionMapper.class);
            List list = auctionMapper.getAuctionList();
            request.setAttribute("list",list);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            MyBatisUtil.closeSqlSession(sqlSession);
        }
    }
}
